import {CreatePictureForm, EditPictureForm, PictureQueryParams, PictureType} from "@/api/picture/types";
import http from "@/utils/http";
import {ListResponse} from "@/types";

/**
 * 图片列表
 * @param params
 * @constructor
 */
export const pictureListApi = async (params: PictureQueryParams) => {
    const res = await http.get<ListResponse<PictureType>>('/v1/picture', params)
    return res.data
}

/**
 * 创建图片
 * @param params
 * @constructor
 */
export const createPictureApi = async (params: CreatePictureForm) => {
    const res = await http.post<PictureType>('/v1/picture', params)
    return res.data
}

/**
 * 修改图片
 * @param params
 * @constructor
 */
export const editPictureApi = async (params: EditPictureForm) => {
    const res = await http.patch('/v1/picture', params)
    return res.data
}

/**
 * 删除图片
 * @constructor
 * @param id
 */
export const deletePictureApi = async (id: number) => {
    const res = await http.delete(`/v1/picture/${id}`, {})
    return res.data
}

/**
 * 打印图片
 * @constructor
 * @param pid
 */
export const printPictureApi = async (pid: number[]) => {
    const res = await http.post<ListResponse<PictureType>>('/v1/picture/print', {pid})
    return res.data
}
